import React, { Component } from 'react'
import Header from '../../components/Header/Header'
import {connect} from 'react-redux'
import { getUser,actions } from '../../store/modules/register';
import { bindActionCreators } from 'redux';


class Register extends Component {
  
 
  render() {
    let {
      user,
      r:{changeUser,doRegister},
      history:{push}
    }=this.props 
    return (
      <div>
        <Header back title='注册'></Header>
          <div>user:{JSON.stringify(user)}</div>
          <div>手机号：<input type="text" value={user.phone} onChange={e=>changeUser('phone',e.target.value)}/></div>
          <div>用户号：<input type="text" value={user.nickname} onChange={e=>changeUser('nickname',e.target.value)}/></div>
          <div>密码：<input type="text" value={user.password} onChange={e=>changeUser('password',e.target.value)}/></div>
          <button onClick={()=>doRegister(push)}>确认注册</button>
      </div>
    )
  }
}

const mapStateToProps=(state)=>{
  return {
    user:getUser(state)
  };
};
const mapDispatchToProps=(dispatch)=>{
  return {
    r:bindActionCreators(actions,dispatch)
  };
};

export default connect(mapStateToProps,mapDispatchToProps)(Register)
